const _function = require("../../utils/functionData.js")
Page({
  data: {
    videoList: [
      // {
      //   id: 1,
      //   cover: 'https://img.yzcdn.cn/vant/cat.jpeg',
      //   title: 'JavaScript入门教程',
      //   duration: '12:34',
      //   url: 'https://example.com/video1.mp4'
      // },
    ],
    _UrlGet_: wx.getStorageSync('img_url')
  },
  onLoad(){
    this.getVideoList()
  },
  // 获取视频列表
  getVideoList(e) {
    console.log('选择时间', getApp().globalData.userInfo);
    const param = {
      
    }
    _function.getVideoList(param, this.getVideoListBack, this)
  },
  getVideoListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      console.log('视频列表',dataAll);
      this.setData({
        videoList: dataAll.rows
      })
      wx.showToast({
        title: dataAll.msg,
        icon: 'none', // 不显示图标
        duration: 1500, // 提示的延迟时间，单位毫秒，默认为 1500
        mask: true, // 是否显示透明蒙层，防止触摸穿透，默认为 `false`
        success: () => {
          // console.log('登录失败提示已显示');
        }
      });
    }
  },
  playVideo: function (event) {
    const videoItem = event.currentTarget.dataset.item;
    // const videoUrl = this.data.videoList.find(item => item.id === videoId).url;
    wx.navigateTo({
      url: `/pages/videoDetail/index?videoItem=${encodeURIComponent(JSON.stringify(videoItem))}`
    });
  }
});